package peoxy.cglible04;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * cglib 动态代理
 */
public class UserDaoIntercepter implements MethodInterceptor {


    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        befor();
        Object invoke = methodProxy.invokeSuper(o, objects);
        after();
        return invoke;
    }

    public void befor() {
        System.out.println("前置增强");
    }

    public void after() {
        System.out.println("后置增强");
    }
}
